﻿using System.Windows.Forms;
using WinAction.Hook;

namespace WinAction.UI
{
	internal class ClipboardUtilWin: Form
	{
		private const int WM_CLIPBOARDUPDATE = 0x031D;

		public ClipboardUtilWin()
		{
			this.CausesValidation = false;
			this.ClientSize = new System.Drawing.Size(0, 0);
			this.Name = "ClipboardUtilWin";
			this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
			this.Load += (s, e) => ClipboardHook.StartHook(this.Handle);
			this.Closed += (s, e) => ClipboardHook.StopHook(this.Handle);
		}

		public new void Show()
		{
			base.Show();
			this.Hide();
		}

		protected override void WndProc(ref System.Windows.Forms.Message m)
		{
			switch (m.Msg)
			{
				case WM_CLIPBOARDUPDATE:
					ClipboardHook.ClipBoardChanged();
					break;
				default:
					break;
			}
			base.WndProc(ref m);
		}
	}
}
